<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<input type="hidden" id="accountId" name="accountId" value="${RequestParameters['accountId']}" />
	<table id="dgtable" class="easyui-datagrid" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'account_name',width:40">公众号名称</th>
			<th data-options="field:'template_name',width:40">模板名称</th>
			<th data-options="field:'create_time',width:40">操作时间</th>
			<th data-options="field:'create_user',width:40">操作人</th>
			<th data-options="field:'operating',width:20,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>模板名称:</span>
		<input  class="easyui-textbox" id="templateName" name="templateName" />
		<span>消息内容:</span>
		<input  class="easyui-textbox" id="content" name="content" />
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="showList();">查询</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="showInfo('create');">新增</a>
	</div>
	</body>
    <script type="text/javascript">
		$(document).ready(function(){
			$('#dgtable').datagrid({
				url: '${app}/weixin/textmgr/list.do',
				method: 'post',
				queryParams: {accountId: $('#accountId').val()},
				singleSelect: true,
                fitColumns: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			});
		});
		function getBtn(value, row, index) {
			return '<a href="javascript:;" class="easyui-linkbutton" onclick="showInfo(\'edit\', \''+row.id+'\');">编辑</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="deleteInfo(\''+row.id+'\');">删除</a>&nbsp;';
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function showList(){
			$('#dgtable').datagrid('load', {
				accountId: $('#accountId').val(),
				templateName: $('#templateName').val(),
				content: $('#content').val()
			});
		}
		function showInfo(method, id){
			parent.easyui.createWindow('消息管理',
					'${app}/weixin/textmgr/edit.do?method='+method+'&accountId='+$('#accountId').val()+'&id='+id,
					'500px', '400px', window.name);
		}
		function deleteInfo(id){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/weixin/textmgr/delete.do', 'id='+id,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								showList();
							}
						}
					);
				}
			});
		}
    </script>
</html>